/******************************************************************************/
/*  Class DS1820                                                              */
/*  PO: S. Maslyakov, rusoil.9@gmail.com                                      */
/*                                                                            */
/*  Revision:     1.1                                                         */
/*  Date:         2010/12/16 17:14:33                                         */
/******************************************************************************/


#ifndef __DS1820_H
#define __DS1820_H


#include "data_types.h"
#include "Ds1820\ds1820_def.h"


//==============================================================================
//  Class DS1820
//==============================================================================
class DS1820
{
public:
  static void Init_Ds1820();
  static void * Get_ds1820_event();
  static uint32_t RomSearch(uint32_t _diff, uint8_t * _id);
  static bool_t ConvertTemp();
  static bool_t ReadTemp(sint16_t * const _pData, const uint8_t * _pUid);

private:
  static void Init_rtos_part();
  static void WriteBit(const uint32_t _bit);
  static void WriteByte(const uint8_t _data);
  static uint8_t ReadByte();
  static uint32_t ReadBit();
  static bool_t MasterReset();
  static void MultiWriteByte(const uint8_t * _pData, const uint32_t _len);
  static void MultiReadByte(const uint32_t _len);
  inline static void Delay(uint32_t _tick) { while(_tick--); }
  inline static void PinHigh() { FIO0DIR_bit.P0_27 = 0; }
  inline static void PinLow() { FIO0DIR_bit.P0_27 = 1; }
  inline static uint32_t GetPin() { return FIO0PIN_bit.P0_27; }

  static uint8_t m_buff[9];
};
//==============================================================================
//==============================================================================


#endif